package io.gitee.zhangbinhub.acp.boot

import io.gitee.zhangbinhub.acp.boot.base.BaseSpringBootScheduledAsyncTask
import io.gitee.zhangbinhub.acp.boot.component.AcpTimerTaskSchedulerCtrl
import io.gitee.zhangbinhub.acp.boot.conf.AcpScheduleConfiguration
import io.gitee.zhangbinhub.acp.boot.log.LogAdapter
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.AutoConfiguration
import org.springframework.boot.autoconfigure.task.TaskSchedulingProperties
import org.springframework.context.annotation.Bean

/**
 * @since JDK 17
 */
@AutoConfiguration(after = [AcpComponentAutoConfiguration::class])
class AcpSchedulerAutoConfiguration {
    @Bean
    fun acpTimerTaskSchedulerCtrl(
        logAdapter: LogAdapter,
        taskSchedulingProperties: TaskSchedulingProperties,
        acpScheduleConfiguration: AcpScheduleConfiguration,
        @Autowired(required = false) baseSpringBootScheduledTaskMap: Map<String, BaseSpringBootScheduledAsyncTask>?
    ) = AcpTimerTaskSchedulerCtrl(
        logAdapter,
        taskSchedulingProperties,
        acpScheduleConfiguration,
        baseSpringBootScheduledTaskMap
    )
}